/**
 * 6064. 不含特殊楼层的最大连续楼层数
 * https://leetcode.cn/contest/weekly-contest-293/problems/maximum-consecutive-floors-without-special-floors/
 */

/**
 * @param {number} bottom
 * @param {number} top
 * @param {number[]} special
 * @return {number}
 */
function maxConsecutive(bottom, top, special) {
  special.sort((a, b) => a - b);
  let max = Math.max(special[0] - bottom, top - special[special.length - 1]);
  for (let i = 1; i < special.length; i += 1) {
    max = Math.max(max, special[i] - special[i - 1] - 1);
  }
  return max;
}

console.log(maxConsecutive(2, 9, [4, 6]) === 3);
console.log(maxConsecutive(6, 8, [7, 6, 8]) === 0);
